import React, { Component, Suspense } from 'react'
import { router, unAuthRouter } from '../router/router'
import { BrowserRouter as Router, Redirect, Route, Switch } from 'react-router-dom'
import AppLayout from "../layout/layout"
//渲染路由
export default class view extends Component {
  render() {
    return (
      <>
        <Router>
          <Suspense fallback={<></>}>
            <Router>
              <Switch>
                <Route path={"/"} exact>
                  <Redirect to={"/login"} />
                </Route>
                <Route path={"/admin"}>
                  <AppLayout>
                    {
                      router.map(r => (<Route key={r.key} path={r.path}>{r.component}</Route>))
                    }
                  </AppLayout>

                </Route>

                <Switch>
                  {
                    unAuthRouter.map(r => <Route key={r.key} path={r.path}>{r.component}</Route>)
                  }
                </Switch>
              </Switch>
            </Router>
          </Suspense>
        </Router>
      </>
    )
  }
}
